package com.lenovo.smarttraffic.zm;


import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.lenovo.smarttraffic.InitApp;
import com.lenovo.smarttraffic.MainActivity;
import com.lenovo.smarttraffic.R;
import com.lenovo.smarttraffic.ui.activity.BaseActivity;
import com.lenovo.smarttraffic.zm_Set.EtcActivity;
import com.lenovo.smarttraffic.zm_Set.User_SignInActivity;

public class SetActivity extends BaseActivity implements View.OnClickListener {

    private String TAG = "fffff";
    private TextView tv_etc_account;
    private TextView tv_signIn;
    private TextView tv_query_ETC;
    private TextView tv_version;
    private Button btn_login_set;
    public static TextView tv_UserNameXX;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }

    private void initView() {
        initToolBar(findViewById(R.id.toolbar), true, "设置");
        tv_etc_account = (TextView) findViewById(R.id.tv_etc_account);
        tv_etc_account.setOnClickListener(this);
        tv_signIn = (TextView) findViewById(R.id.tv_signIn);
        tv_signIn.setOnClickListener(this);
        tv_query_ETC = (TextView) findViewById(R.id.tv_query_ETC);
        tv_query_ETC.setOnClickListener(this);
        tv_version = (TextView) findViewById(R.id.tv_version);
        tv_version.setOnClickListener(this);
        btn_login_set = (Button) findViewById(R.id.btn_login_set);
        btn_login_set.setOnClickListener(this);
        //跨越activity  调用 控件
        tv_UserNameXX = MainActivity.tv_UserNameXX;
//      tv_UserNameXX = navigationView.getHeaderView(0).findViewById(R.id.tv_UserNameXX);
//      View headerLayout = navigationView.inflateHeaderView(R.layout.);
//      panel = headerLayout.findViewById(R.id.viewId);
        if (InitApp.isRegister) {
            btn_login_set.setEnabled(true);
            GradientDrawable gradientDrawable = (GradientDrawable) btn_login_set.getBackground();
            gradientDrawable.setColor(Color.parseColor("#1D998D"));
        } else {
            btn_login_set.setEnabled(false);
            GradientDrawable gradientDrawable = (GradientDrawable) btn_login_set.getBackground();
            gradientDrawable.setColor(Color.parseColor("#888383"));
        }
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_set;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_login_set:
                InitApp.isRegister = false;
                InitApp.signIn = false;
                tv_UserNameXX.setText("点击头像登录");
                finish();
                Log.e(TAG, "onClick: " + InitApp.isRegister);
                break;
            case R.id.tv_signIn:
                startActivity(new Intent(this, User_SignInActivity.class));
                break;
            case R.id.tv_query_ETC:
                startActivity(new Intent(this, EtcActivity.class));
                break;
        }
    }
}
